package com.litong.litongjiaoyu.service.impl;

import com.litong.litongjiaoyu.dao.ClassScheduleDao;
import com.litong.litongjiaoyu.entity.SysClassschedule;
import com.litong.litongjiaoyu.service.ClassScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName SysClassScheduleServiceImpl
 * @Description 课表业务层
 * @Author jingz
 * @Date 2019/11/11 13:41
 * @Version 1.0
 **/
@Service
public class ClassScheduleServiceImpl implements ClassScheduleService {


    @Autowired
    private ClassScheduleDao classScheduleDao;

    /**
     * 添加课程
     *
     * @param sysClassschedule
     * @return
     */
    @Transactional
    @Override
    public int add(List<SysClassschedule> sysClassschedule) {
        return classScheduleDao.add(sysClassschedule);
    }

    /**
     * 批量删除课表
     *
     * @param list
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int batchRemove(List<SysClassschedule> list) {
        return classScheduleDao.batchRemove(list);
    }


    /**
     * 删除与其相关的课表
     * @param campus 校区
     * @param classname 班级
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int remove(String campus, String classname) {
        return classScheduleDao.remove(campus, classname);
    }

    /**
     * 更新课表内容
     * @param sysClassschedule 获取到的课表内容
     * @return int
     */

    @Transactional
    @Override
    public int update(SysClassschedule sysClassschedule) {
        return classScheduleDao.update(sysClassschedule);
    }

    /**
     * 根据id获取课表信息
     * @param id 绑定的id值
     * @return SysClassschedule
     */
    @Override
    public List<SysClassschedule> get(long id) {
        return classScheduleDao.get(id);
    }

    /**
     * 获取全部的课表内容
     * @return List<SysClassschedule>
     */
    @Override
    public List<SysClassschedule> query() {
        return classScheduleDao.query();
    }

    /**
     * 根据班级查询相应的课表
     * @param className 班级名称
     * @return SysClassschedule
     */
    @Override
    public List<SysClassschedule> GetByClassName(String className, String campus) {
        return classScheduleDao.GetByClassName(className, campus);
    }
}
